package model

import "time"

const TableNameUser = "users"

type User struct {
	UserID     int32     `gorm:"column:user_id;primaryKey;autoIncrement:true" json:"user_id"`
	Username   string    `gorm:"column:username;not null" json:"username"`
	Password   string    `gorm:"column:password;not null" json:"password"`
	Avatar     string    `gorm:"column:avatar" json:"avatar"`
	Phone      string    `gorm:"column:phone" json:"phone"`
	Role       string    `gorm:"column:role;not null" json:"role"`
	CreateTime time.Time `gorm:"column:create_time;not null" json:"create_time"`
	Status     string    `gorm:"column:status;not null" json:"status"`
}

func (*User) TableName() string {
	return TableNameUser
}

const TableNameBorrowRecord = "borrow_records"

type BorrowRecord struct {
	BorrowRecordsID int32     `gorm:"column:borrow_records_id;primaryKey;autoIncrement:true" json:"borrow_records_id"`
	UserID          int32     `gorm:"column:user_id" json:"user_id"`
	Username        string    `gorm:"-" json:"username"`
	EquipmentID     int32     `gorm:"column:equipment_id" json:"equipment_id"`
	Name            string    `gorm:"column:name;null" json:"name"`
	BorrowCount     int32     `gorm:"column:borrow_count" json:"borrow_count"`
	BorrowTime      time.Time `gorm:"column:borrow_time" json:"borrow_time"`
	ReturnTime      time.Time `gorm:"column:return_time" json:"return_time"`
	Status          string    `gorm:"column:status;not null" json:"status"`
}

func (*BorrowRecord) TableName() string {
	return TableNameBorrowRecord
}

const TableNameEquipmentCategory = "equipment_categories"

type EquipmentCategory struct {
	CategoryID  int32  `gorm:"column:category_id;primaryKey;autoIncrement:true" json:"category_id"`
	Name        string `gorm:"column:name;not null" json:"name"`
	Description string `gorm:"column:description" json:"description"`
}

func (*EquipmentCategory) TableName() string {
	return TableNameEquipmentCategory
}

const TableNameEquipment = "equipments"

type Equipment struct {
	EquipmentID  int32     `gorm:"column:equipment_id;primaryKey;autoIncrement:true" json:"equipment_id"`
	Name         string    `gorm:"column:name;not null" json:"name"`
	Quantity     int32     `gorm:"column:quantity" json:"quantity"`
	Status       string    `gorm:"column:status;not null" json:"status"`
	CategoryID   int32     `gorm:"column:category_id" json:"category_id"`
	CategoryName string    `gorm:"-" json:"category_name"`
	CreateTime   time.Time `gorm:"column:create_time;null" json:"create_time"`
}

type CategoryName struct {
	Name string `gorm:"column:name" json:"name"`
}

func (*Equipment) TableName() string {
	return TableNameEquipment
}

const TableNameNotification = "notifications"

type Notification struct {
	NotificationID   int32     `gorm:"column:notification_id;primaryKey;autoIncrement:true" json:"notification_id"`
	UserID           int32     `gorm:"column:user_id" json:"user_id"`
	Message          string    `gorm:"column:message;not null" json:"message"`
	SentTime         time.Time `gorm:"column:sent_time;not null" json:"sent_time"`
	ReadStatus       string    `gorm:"column:read_status;not null" json:"read_status"`
	NotificationType string    `gorm:"column:notification_type" json:"notification_type"`
}

func (*Notification) TableName() string {
	return TableNameNotification
}

const TableNameReservationRequest = "reservation_requests"

type ReservationRequest struct {
	RequestID    int32     `gorm:"column:request_id;primaryKey;autoIncrement:true" json:"request_id"`
	UserID       int32     `gorm:"column:user_id" json:"user_id"`
	EquipmentID  int32     `gorm:"column:equipment_id" json:"equipment_id"`
	RequestCount int32     `gorm:"column:request_count" json:"request_count"`
	StartTime    time.Time `gorm:"column:start_time;not null" json:"start_time"`
	EndTime      time.Time `gorm:"column:end_time;not null" json:"end_time"`
	Status       string    `gorm:"column:status;not null" json:"status"`
	RequestTime  time.Time `gorm:"column:request_time;not null" json:"request_time"`
}

func (*ReservationRequest) TableName() string {
	return TableNameReservationRequest
}

type PaginationList struct {
	Count       interface{} `json:"count"`
	TotalPages  interface{} `json:"total_pages"`
	CurrentPage interface{} `json:"current_page"`
	Size        interface{} `json:"size"`
}
